﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using LibDll;
using HelperUnity; 

namespace IYASAKANet_CDDY
{
    public static class dataOperation
    {
        /// <summary>
        /// 保存基本信息.
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENVCarInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            string strSql = string.Empty;
            try
            {
                strSql = "select Count(*) from ENV_CARINFO where VIN='" + strInfos[0] + "'"; 

                DataSet ds = SqlOperator.getSet(strSql);

                
                if (ds!=null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_CARINFO set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', SB='" + strInfos[3] + "',SCCMC='" + strInfos[4] 
                        + "',SCCDZ='" + strInfos[5] + "',SCDATE='" + strInfos[6] + "',FDJH='" + strInfos[7] + "',FDJSB='" + strInfos[8] + "',FDJSCCDZ='" + strInfos[9] + "' ";
                    strSql += " where VIN='"+ strInfos[0] + "'";
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_CARINFO(VIN,VEHICLEMODEL, XXGKBH, SB,SCCMC,SCCDZ,SCDATE,FDJH,FDJSB,FDJSCCDZ) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "', '" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] +
                        "','" + strInfos[6] + "','" + strInfos[7] + "','" + strInfos[8] + "','" + strInfos[9] + "')";
                    
                }

                

                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult>=0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
                else
                {
                    ret.IsSuccess = false;
                    ret.Message = strSql;
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message + strSql;
            }

            return ret;
        }

        /// <summary>
        /// 保存瞬态/简易瞬态.
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_TRANSIENTInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            string strSql = string.Empty;
            try
            {
                strSql = "select Count(*) from ENV_TRANSIENT where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

                
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    string createdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    strSql = "update ENV_TRANSIENT set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', VRHC='" + strInfos[3] + "',VLHC='" + strInfos[4] 
                        + "',VRCO='" + strInfos[5] + "',VLCO='" + strInfos[6] + "',VRNOX='" + strInfos[7] + "',VLNOX='" + strInfos[8] + "', CREATEDATE='" + createdate + "'";
                    strSql += " where VIN='" + strInfos[0]+"'";
                    
                }
                else
                {
                    // Insert
                    string createdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    strSql = "insert into ENV_TRANSIENT(VIN,VEHICLEMODEL, XXGKBH, VRHC,VLHC,VRCO,VLCO,VRNOX,VLNOX,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "','" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] 
                        + "','" + strInfos[6] + "','" + strInfos[7] + "','" + strInfos[8] + "', '" + createdate + "')";
                    
                } 

                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
                else
                {
                    ret.IsSuccess = false;
                    ret.Message = strSql;
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message + strSql;
            }

            return ret;
        }

        /// <summary>
        /// 保存ZYJS
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_FREEMETHODInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_FREEMETHOD where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

                
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    string createdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    strSql = "update ENV_FREEMETHOD set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', RATEREV='" + strInfos[3] + "',REV='" + strInfos[4] 
                        + "',SMOKEK1='" + strInfos[5] + "',SMOKEK2='" + strInfos[6] + "',SMOKEK3='" + strInfos[7] + "',SMOKEAVG='" + strInfos[8] + "',SMOKEKLIMIT='" + strInfos[9] + "', CREATEDATE='"+ createdate + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                   
                }
                else
                {
                    // update
                    strSql = "insert into ENV_FREEMETHOD(VIN,VEHICLEMODEL, XXGKBH, RATEREV,REV,SMOKEK1,SMOKEK2,SMOKEK3,SMOKEAVG,SMOKEKLIMIT,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "', '" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] + "','" + strInfos[6] 
                        + "','" + strInfos[7] + "','" + strInfos[8] + "', '" + strInfos[9] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                     
                }

                 
                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }

        /// <summary>
        /// 保存SDS
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_IDLESPEEDInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_IDLESPEED where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

                 
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_IDLESPEED set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', REAC='" + strInfos[3] + "',LRCO='" + strInfos[4] + "',LLCO='" + strInfos[5] 
                        + "',LRHC='" + strInfos[6] + "',LLHC='" + strInfos[7] + "',HRCO='" + strInfos[8] + "',HLCO='" + strInfos[9] + "', HRHC='" + strInfos[10] + "',HLHC='" + strInfos[11] 
                        + "',LEACMAX='" + strInfos[12] + "',LEARMIN='" + strInfos[13] + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                    
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_IDLESPEED(VIN,VEHICLEMODEL, XXGKBH, REAC,LRCO,LLCO,LRHC,LLHC,HRCO,HLCO,HRHC,HLHC,LEACMAX,LEARMIN,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "', '" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] + "','" + strInfos[6] 
                        + "','" + strInfos[7] + "','" + strInfos[8] + "','" + strInfos[9] + "','" + strInfos[10] + "','" + strInfos[11] + "','" + strInfos[12] + "','" + strInfos[13] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                   
                }

                
                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }

        /// <summary>
        /// 保存ENV_INSTANTMETHOD
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_INSTANTMETHODInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_INSTANTMETHOD where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

                 
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_INSTANTMETHOD set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', VRCO='" + strInfos[3] + "',VLCO='" + strInfos[4] 
                        + "',VRHCNOX='" + strInfos[5] + "',VLHCNOX='" + strInfos[6] + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                    
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_INSTANTMETHOD(VIN,VEHICLEMODEL, XXGKBH, VRCO,VLCO,VRHCNOX,VLHCNOX,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "','" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] + "','" 
                        + strInfos[6] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                   
                }

                 
                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }


        /// <summary>
        /// 保存ENV_METHOD
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_METHODInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_METHOD where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

                
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_METHOD set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', RATEREVUP='" + strInfos[3] + "',RATEREVDOWN='" + strInfos[4] 
                        + "',REV100='" + strInfos[5] + "',MAXPOWER='" + strInfos[6] + "',MAXPOWERLIMIT='" + strInfos[7] + "',SMOKE100='" + strInfos[8] + "',SMOKE80='" + strInfos[9] 
                        + "',SMOKELIMIT='" + strInfos[10] + "',NOX='" + strInfos[11] + "',NOXLIMIT='" + strInfos[12] + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                   
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_METHOD(VIN,VEHICLEMODEL,XXGKBH, RATEREVUP,RATEREVDOWN,REV100,MAXPOWER,MAXPOWERLIMIT,SMOKE100,SMOKE80,SMOKELIMIT,NOX,NOXLIMIT,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "','" + strInfos[2] + "', '" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] + "','" + strInfos[6] 
                        + "','" + strInfos[7] + "','" + strInfos[8] + "','" + strInfos[9] + "','" + strInfos[10] + "','" + strInfos[11] + "','" + strInfos[12] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                     
                }
 
                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }

        /// <summary>
        /// 保存ENV_STEADYSTATE
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_STEADYSTATEInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_STEADYSTATE where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

               
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_STEADYSTATE set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', ARHC5025='" + strInfos[3] + "',ALHC5025='" + strInfos[4] 
                        + "',ARCO5025='" + strInfos[5] + "',ALCO5025='" + strInfos[6] + "',ARNOX5025='" + strInfos[7] + "',ALNOX5025='" + strInfos[8] + "',ARHC2540='" + strInfos[9] 
                        + "',ALHC2540='" + strInfos[10] + "',ARCO2540='" + strInfos[11] + "',ALCO2540='" + strInfos[12] + "',ARNOX2540='" + strInfos[13] + "',ALNOX2540='" + strInfos[14] 
                        + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                     
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_STEADYSTATE(VIN,VEHICLEMODEL,XXGKBH, ARHC5025,ALHC5025,ARCO5025,ALCO5025,ARNOX5025,ALNOX5025,ARHC2540,ALHC2540,ARCO2540,ALCO2540,ARNOX2540,ALNOX2540,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "','" + strInfos[2] + "', '" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] + "','" + strInfos[6]
                        + "','" + strInfos[7] + "','" + strInfos[8] + "','" + strInfos[9] + "','" + strInfos[10] + "','" + strInfos[11] + "','" + strInfos[12] + "','" + strInfos[13] 
                        + "','" + strInfos[14] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                   
                }
 
                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }

        /// <summary>
        /// 保存ENV_PARAM
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_PARAMInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_PARAM where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

               
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_PARAM set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', RH='" + strInfos[3] + "',ET='" + strInfos[4] + "',AP='"
                        + strInfos[5] + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                     
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_PARAM(VIN,VEHICLEMODEL,XXGKBH,  RH,ET,AP,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "', '" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                    
                }

                

                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }

        /// <summary>
        /// 保存ENV_TESTEQUIPMENT
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_TESTEQUIPMENTInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_TESTEQUIPMENT where VIN='" + strInfos[0] + "'";

                DataSet ds = SqlOperator.getSet(strSql);

                string strBDDate = "2000-01-01 00:01:01";
                if (string.IsNullOrEmpty(strInfos[5]) == false && strInfos[5].Length == 8)
                {
                    strBDDate = strInfos[5].Substring(0, 4) + "-" + strInfos[5].Substring(4, 2) + "-" + strInfos[5].Substring(6, 2) + " 12:13:14";
                }

               
                if (ds!=null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_TESTEQUIPMENT set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', ANALYMANUF='" + strInfos[3] + "',ANALYMODEL='" 
                        + strInfos[4] + "',ANALYDATE='" + strBDDate + "',ANALYNAME='" + strInfos[6] + "',DYNOMODEL='" + strInfos[7] + "',DYNOMANUF='" + strInfos[8] + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                    
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_TESTEQUIPMENT(VIN,VEHICLEMODEL,XXGKBH,ANALYMANUF,ANALYMODEL,ANALYDATE,ANALYNAME,DYNOMODEL,DYNOMANUF,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "','" + strInfos[3] + "','" + strInfos[4] + "','','" + strInfos[6] + "','"
                        + strInfos[7] + "','" + strInfos[8] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                   
                }

                

                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }

        /// <summary>
        /// 保存ENV_TESTINFO
        /// </summary>
        /// <param name="strInfos"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_TESTINFOInfo(string[] strInfos)
        {
            ReturnInfo ret = new ReturnInfo();
            string strSql = string.Empty;
            try
            {
                strSql = "select Count(*) from ENV_TESTINFO where VIN='" + strInfos[0] + "'";

                //string strSql = "select Count(*) from ENV_TESTINFO";

                DataSet ds = SqlOperator.getSet(strSql);

              
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_TESTINFO set VEHICLEMODEL='" + strInfos[1] + "', XXGKBH='" + strInfos[2] + "', TESTTYPE='" + strInfos[3] + "',TESTNO='" + strInfos[4] 
                        + "',TESTDATE='" + strInfos[5] + "',APASS='" + strInfos[6] + "',OPASS='" + strInfos[7] + "',OTESTDATE='" + strInfos[8] + "',EPASS='" + strInfos[9]
                        + "',RESULT='" + strInfos[10] + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + strInfos[0] + "'";
                    
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_TESTINFO(VIN,VEHICLEMODEL,XXGKBH,TESTTYPE,TESTNO,TESTDATE,APASS,OPASS,OTESTDATE,EPASS,RESULT,CREATEDATE) ";
                    strSql += "values('" + strInfos[0] + "','" + strInfos[1] + "', '" + strInfos[2] + "','" + strInfos[3] + "','" + strInfos[4] + "','" + strInfos[5] + "','" + strInfos[6]
                        + "','" + strInfos[7] + "','" + strInfos[8] + "','" + strInfos[9] + "','" + strInfos[10] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                     
                }

               
                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
                else
                {
                    ret.IsSuccess = false;
                    ret.Message = strSql;
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message + strSql;
            }

            return ret;
        }

        /// <summary>
        /// Save ENV_MODULE
        /// </summary>
        /// <param name="VIN"></param>
        /// <param name="VEHICLEMODEL"></param>
        /// <param name="XXGKBH"></param>
        /// <param name="MODULEID"></param>
        /// <param name="CALID"></param>
        /// <param name="CVN"></param>
        /// <returns></returns>
        public static ReturnInfo SaveENV_MODULE(string VIN, string VEHICLEMODEL, string XXGKBH, string MODULEID, string CALID, string CVN, string strPROCESSID)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = string.Empty;

                // Insert
                strSql = "insert into ENV_MODULE(VIN,VEHICLEMODEL,XXGKBH,MODULEID,CALID,CVN,PROCESSDATABATCH) ";
                strSql += "values('" + VIN + "','" + VEHICLEMODEL + "','" + XXGKBH + "','" + MODULEID + "','" + CALID + "','" + CVN + "','" + strPROCESSID + "')";

                int iResult = SqlOperator.ExecuteNonQuery(strSql);
                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }

        public static ReturnInfo SaveENV_PROCESSDATA(string VIN, string VEHICLEMODEL, string XXGKBH, string OBD, string ODO, string strProcessID)
        {
            ReturnInfo ret = new ReturnInfo();
            try
            {
                string strSql = "select Count(*) from ENV_PROCESSDATA where VIN='" + VIN + "'";

                DataSet ds = SqlOperator.getSet(strSql);

                if (string.IsNullOrEmpty(ODO))
                {
                    ODO = "null";
                }
                else
                {
                    ODO = "'" + ODO + "'";
                }

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                {
                    // update
                    strSql = "update ENV_PROCESSDATA set VEHICLEMODEL='" + VEHICLEMODEL + "', XXGKBH='" + XXGKBH + "', OBD='" + OBD + "',ODO=" + ODO + ",PROCESSDATABATCH='" + strProcessID + "',CREATEDATE='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                    strSql += " where VIN='" + VIN + "'";
                }
                else
                {
                    // Insert
                    strSql = "insert into ENV_PROCESSDATA(VIN,VEHICLEMODEL,XXGKBH,OBD,ODO,PROCESSDATABATCH,CREATEDATE) ";
                    strSql += "values('" + VIN + "','" + VEHICLEMODEL + "', '" + XXGKBH + "','" + OBD + "',"+ ODO + ",'" + strProcessID + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"; 
                }

                int iResult = SqlOperator.ExecuteNonQuery(strSql);

                if (iResult >= 0)
                {
                    ret.IsSuccess = true;
                    ret.Message = "执行成功";
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess = false;
                ret.Message = ex.Message;
            }

            return ret;
        }
    }
}
